#!/bin/sh
str=${CONFIG_FILES}
for i in `echo "$str" | sed 's/;/\n/g'`
do
   nacosstr=${i%%>*}
   dataid=${nacosstr##*@}
   nacosstr=${nacosstr%@*}
   group=${nacosstr##*@}
   tenant=${i%%@*}
   path=${i##*>}
   for j in `echo "$path" | sed 's/,/\n/g'`
   do
     echo 'curl-->dataid:'${dataid}' tenant:'${tenant}' path:'${j}' group:'${group};
     echo 'window.RPConfig = '`curl -L --request GET \
     --url http://${NACOS}/nacos/v1/cs/configs?tenant=${tenant}'&dataId='${dataid}'&group'=${group} \
     --header 'Cache-Control: no-cache' \
     --header 'Content-Type: application/json'` >${j}
   done
done;

sed -i "48c proxy_pass  ${gateway_proxy_pass};" /etc/nginx/nginx.conf
exec nginx -g 'daemon off;'
